
Page({
    data: {
      tabArray: ['等额本息', '等额本金', '本息/本金'],
      tabIndex: 0,
      result: {}, // 获取计算结果
    },
    onLoad(t) {
      let res = wx.getStorageSync('_mortgage');
      if (res) {
        this.setData({ result: JSON.parse(res) });
      } else {
        console.warn('Not Data!!!');
        wx.redirectTo({ url: '/page/mortgage/mortgage' });
      }
    },
    onReady() {},
    onShow() {},
    onHide() {},
    onUnload() {},
    onPullDownRefresh() {},
    onReachBottom() {},
    onShareAppMessage() {},
    chooseTabBar(e) { // 切换显示页
      let target = e.currentTarget.dataset;
      if (target.index !== this.data.tabIndex) {
        this.setData({
          tabIndex: Number(target.index)
        })
      }
    },
    toPage(e) { // 页面跳转
      if (e.currentTarget.dataset.url) {
        e.currentTarget.dataset.type === 'back' ? wx.navigateBack({
          delta: 1 //返回的页面数，如果 delta 大于现有页面数，则返回到首页,
        }) : wx.navigateTo({
          url: e.currentTarget.dataset.url
        })
      } else {
        console.warn('Not Page Url')
      }
    }
  })
